import 'package:connectivity_plus/connectivity_plus.dart';

class NetUtil {
  /// 网络是否连接
  // ignore: missing_return
  static Future<bool> isNetConnected() async {
    final Connectivity _connectivity = Connectivity();
    ConnectivityResult connectivityResult =
        await _connectivity.checkConnectivity();
    return connectivityResult.toString() != ConnectivityResult.none;
  }

  /// 是否是WIFI
  static Future<bool> isWifi() async {
    final Connectivity _connectivity = Connectivity();
    ConnectivityResult connectivityResult =
        await _connectivity.checkConnectivity();
    return connectivityResult == ConnectivityResult.wifi;
  }

  /// 是否是流量
  static Future<bool> isMobile() async {
    final Connectivity _connectivity = Connectivity();
    ConnectivityResult connectivityResult =
        await _connectivity.checkConnectivity();
    return connectivityResult == ConnectivityResult.mobile;
  }
}
